import { _decorator, Component, EventTouch, find, instantiate, Node, NodePool, Prefab, Size, size, tween, Tween, UITransform, v2, v3, Vec2, Vec3, Widget } from 'cc';
import { Ab_DataTransfer_bA } from '../../../A-FRAME/A-LIB/lib.b.data';
import { Ab_AudioManager_bA } from '../../manager/audio-manager';
import Ab_GameDC_bA from '../../manager/data.game.center';
import Ab_GameAssets_bA from '../../manager/game.assets';
import { Ab_Tile_bA } from '../../ui/tile';
import { Ab_GameGuide_bA } from './guide.game';
const { ccclass, property } = _decorator;

@ccclass('Ab_GameGamdBoard_bA')
export class Ab_GameGameBoard_bA extends Component {
	private static ins: Ab_GameGameBoard_bA;
	private static Ab_select_call_list_bA: Array<(record: {tier: number, coor: Vec2, tile: Ab_Tile_bA})=>any> = [];
	public static Ab_onSelectTile_bA(call: (record: {tier: number, coor: Vec2, tile: Ab_Tile_bA})=>any){
		Ab_GameGameBoard_bA.Ab_select_call_list_bA.push(call);
	}

	private static Ab_tile_pool_bA = new NodePool();
	private static Ab_getTile_bA(){
		let node = Ab_GameGameBoard_bA.Ab_tile_pool_bA.get() || instantiate(Ab_GameGameBoard_bA.ins.Ab_tile_prefab_bA);

		return node.getComponent(Ab_Tile_bA);
	}

	public static Ab_recycleTile_bA(tile: Ab_Tile_bA){
		if(!tile) return void 0;
		Ab_GameGameBoard_bA.Ab_tile_pool_bA.put(tile.node);
		tile.node.active = true;
	}

	@property(UITransform)
	private Ab_ui_container_bA: UITransform = null;
	@property(Prefab)
	private Ab_tile_prefab_bA: Prefab = null;

	private Ab_uitrans_bA: UITransform;

	private Ab_vecas_bA: abi.Ab_cc_bA.Ab_VecAssist_bA;

	/** 棋盘尺寸 */
	private Ab_size_bA = size(8, 8);
	private Ab_tile_size_bA: Size;
	private Ab_tween_speed_bA = 0;

	private Ab_tile_records_bA: Array<{
		tier: number,
		node: Node,
		tiles: Array<{coor: Vec2, tile: Ab_Tile_bA}>
	}> = [];
	private Ab_tile_count_bA = 0;

	private Ab_prms_render_bA: Promise<'end'>;

	public get Ab_tileCount_bA(){
		return this.Ab_tile_count_bA;
	}

	protected onLoad(){
		Ab_GameGameBoard_bA.ins = this;
		this.Ab_init_bA();
	}

	protected start(){
		let wgt = this.node.getComponent(Widget);
		if(!wgt) wgt = this.node.addComponent(Widget);
		wgt.left = 0; wgt.right = 0;
		wgt.bottom = 570; wgt.top = abi.Ab_cc_bA.Ab_is_long_screen_bA ? 500 : 400;
		wgt.updateAlignment();
		wgt.enabled = false;
		wgt.destroy();

		this.Ab_ui_container_bA.setContentSize(this.Ab_uitrans_bA.contentSize);
		this.Ab_ui_container_bA.node.setPosition(Vec3.ZERO.clone());

		this.Ab_vecas_bA.Ab_vec_bA.x = this.Ab_vecas_bA.Ab_over_right_bA;
		this.Ab_vecas_bA.Ab_vec_bA.y = this.Ab_uitrans_bA.node.position.y;
		this.Ab_uitrans_bA.node.setPosition(this.Ab_vecas_bA.Ab_vec_bA);

		let tile_width = this.Ab_uitrans_bA.width / this.Ab_size_bA.width;
		let tile_height = this.Ab_uitrans_bA.height / this.Ab_size_bA.height;
		this.Ab_tile_size_bA = Ab_Tile_bA.Ab_calculateSizeByBlock_bA(tile_width, tile_height).block;
		this.Ab_tween_speed_bA = Math.max(this.Ab_tile_size_bA.width, this.Ab_tile_size_bA.height) / 0.1;
	}

	private Ab_update_call_list_bA: Array<[Function, any[], abi.Ab_NudityPromise_bA<any>]> = [];
	protected update(dt: number){
		if(this.Ab_update_call_list_bA.length>0){
			let [call, args, np] = this.Ab_update_call_list_bA.pop();
			np.Ab_resolve_bA(call(...args));
		}
	}

	protected onDestroy(){
		this.Ab_listening_list_bA.forEach(reg=>Ab_DataTransfer_bA.Ab_cancel_bA(reg));
	}

	private Ab_updateCallBack_bA<A extends any[], R>(call: (...args: [...A])=>R, ...args: A){
		let np = new abi.Ab_NudityPromise_bA<R>();
		this.Ab_update_call_list_bA.unshift([call, args, np]);
		return np.Ab_promise_bA;
	}

	private Ab_updateFor_bA<A extends any[], R>(list: A, call: (el: A[number], index: number, arr: A)=>R){
		return Promise.all(list.map((el, index, arr)=>this.Ab_updateCallBack_bA(call, el, index, arr)));
	}

	private Ab_init_bA(){
		this.Ab_uitrans_bA = this.node.getComponent(UITransform);

		this.Ab_vecas_bA = new abi.Ab_cc_bA.Ab_VecAssist_bA(this.Ab_uitrans_bA.node);

		this.Ab_listening_bA();

		this.node.on(Node.EventType.TOUCH_END, this.Ab_touchEnd_bA, this);
	}

	private Ab_listening_list_bA: ReturnType<typeof Ab_DataTransfer_bA.Ab_follow_bA>[] = [];
	private Ab_listening_bA(){
		this.Ab_listening_list_bA.push(
			Ab_DataTransfer_bA.Ab_follow_bA(Ab_GameDC_bA.Ab_Trigger_bA, 'Ab_UIGame_bA', (_, show)=>{
				if(_==show) return void 0;
				if(show) this.Ab_enter_bA().then(()=>this.Ab_initGuide_bA());
				else this.Ab_leave_bA();
			}, false),
		);

		if(Ab_GameDC_bA.Ab_Trigger_bA.Ab_PreLoadTiles_bA){
			this.Ab_preLoadTiles_bA();
		}else{
			let reg = Ab_DataTransfer_bA.Ab_follow_bA(Ab_GameDC_bA.Ab_Trigger_bA, 'Ab_PreLoadTiles_bA', ()=>{
				this.Ab_preLoadTiles_bA();
				Ab_DataTransfer_bA.Ab_cancel_bA(reg);
			}, false);
		}
	}

	private async Ab_enter_bA(duration?: number){
		duration = duration ?? 0.5;
		let np = new abi.Ab_NudityPromise_bA<'end'>();
		this.Ab_ui_container_bA.node.active = true;

		await Promise.resolve(this.Ab_prms_render_bA);

		Ab_AudioManager_bA.Ab_playEffect_bA(Ab_AudioManager_bA.Ab_EAudio_bA.Ab_EF_BOARD_bA);

		this.Ab_vecas_bA.Ab_vec_bA.x = this.Ab_vecas_bA.Ab_center_bA.x;
		this.Ab_vecas_bA.Ab_vec_bA.y = this.Ab_uitrans_bA.node.position.y;

		Tween.stopAllByTarget(this.Ab_uitrans_bA.node);
		tween(this.Ab_uitrans_bA.node)
		.to(duration, {position: this.Ab_vecas_bA.Ab_vec_bA}, {easing: 'cubicOut'})
		.call(()=>np.Ab_resolve_bA('end'))
		.start();

		return np.Ab_promise_bA;
	}

	private Ab_leave_bA(duration?: number){
		duration = duration ?? 0.5;

		this.Ab_vecas_bA.Ab_vec_bA.x = this.Ab_vecas_bA.Ab_over_right_bA;
		this.Ab_vecas_bA.Ab_vec_bA.y = this.Ab_uitrans_bA.node.position.y;

		Tween.stopAllByTarget(this.Ab_uitrans_bA.node);
		tween(this.Ab_uitrans_bA.node)
		.to(duration, {position: this.Ab_vecas_bA.Ab_vec_bA}, {easing: 'cubicOut'})
		.start();
	}

	private Ab_touch_bA = {
		Ab_location_bA: v2(),
		Ab_select_bA: v3(),
		Ab_positon_bA: v3(),
	}
	private Ab_touchEnd_bA(event: EventTouch){
		if(Ab_GameDC_bA.Ab_Status_bA.Ab_shuffling_bA) return void 0;
		event.getUILocation(this.Ab_touch_bA.Ab_location_bA);

		this.Ab_selectTile_bA(this.Ab_touch_bA.Ab_location_bA);
	}

	/**
	 * 根据给定的世界坐标选取砖块
	 * @param x
	 * @param y
	 */
	private Ab_selectTile_bA(x: Vec3|Vec2|number, y?: number){
		if(x instanceof Vec3) this.Ab_touch_bA.Ab_select_bA.set(x);
		else if(x instanceof Vec2) this.Ab_touch_bA.Ab_select_bA.set(x.x, x.y);
		else this.Ab_touch_bA.Ab_select_bA.set(x, y);

		this.Ab_ui_container_bA.convertToNodeSpaceAR(this.Ab_touch_bA.Ab_select_bA, this.Ab_touch_bA.Ab_positon_bA);

		let select_item: typeof this.Ab_tile_records_bA[number]['tiles'][number];
		let tier: number;
		let distance = v3();
		for(let {tier: t, tiles} of this.Ab_tile_records_bA){
			select_item = tiles.find(el=>{
				if(el.tile.Ab_Light_bA){
					Vec3.subtract(distance, el.tile.node.position, this.Ab_touch_bA.Ab_positon_bA);
					return [distance.x/this.Ab_tile_size_bA.width, distance.y/this.Ab_tile_size_bA.height].every(v=>Math.abs(v)<0.5);
				}
			});
			if(select_item){
				tier = t;
				break;
			}
		}

		if(select_item) Ab_GameGameBoard_bA.Ab_select_call_list_bA.forEach(call=>call({tier, ...select_item}));
	}

	/** 预加载砖块 */
	private async Ab_preLoadTiles_bA(){
		let round_layout = await Ab_GameAssets_bA.Ab_loadRoundLayout_bA('level_4');
		let count = round_layout.reduce((acc, cur)=>acc+cur.coor.length, 0);
		let cut_length = Math.floor(count / 5000 * 15);

		for(let progress = 0; progress < count; progress += cut_length){
			this.Ab_updateCallBack_bA((p, t, c)=>{
				Ab_GameDC_bA.Ab_Trigger_bA.Ab_PreLoadTilesProgress_bA = t + ',' + (p+c);
				while(c>0){
					Ab_GameGameBoard_bA.Ab_tile_pool_bA.put(instantiate(this.Ab_tile_prefab_bA));
					c--;
				}
			}, progress, count, cut_length);
		}
	}

	private Ab_cleanBoard_bA(){

		this.Ab_tile_records_bA = [];

		this.Ab_ui_container_bA.node.children.filter(n=>n.name.startsWith('tier:')).forEach((node, index)=>{
			node.getComponentsInChildren(Ab_Tile_bA).forEach(t=>Ab_GameGameBoard_bA.Ab_recycleTile_bA(t));
			node.name = 'tier:'+(index+1);
		});

		this.Ab_ui_container_bA.node.children.filter(n=>!n.name.startsWith('tier:')).forEach(n=>n.destroy());

		Reflect.deleteProperty(this, 'Ab_loop_bA');
	}

	private Ab_refreshLight_bA(tier_idx: number){
		let index = this.Ab_tile_records_bA.findIndex(el=>el.tier==tier_idx);
		let distance = v2();
		for(let idx = index-1; idx >= 0; idx--){
			let tier = this.Ab_tile_records_bA[idx];
			for(let item of tier.tiles){
				tile_light: for(let i = idx+1; i < this.Ab_tile_records_bA.length; i++){
					for(let el of this.Ab_tile_records_bA[i].tiles){
						Vec2.subtract(distance, el.coor, item.coor);
						if([distance.x, distance.y].every(v=>Math.abs(v)<1)){
							item.tile.Ab_setLight_bA(false);
							break tile_light;
						}
					}
					item.tile.Ab_setLight_bA(true);
				}
			}
		}
	}

	/**
	 * 渲染关卡数据
	 * @param data 关卡数据
	 */
	public Ab_renderBoard_bA(data: Array<{tier: number, element: Array<{id: string, coor: Array<Vec2>}>}>){
		this.Ab_cleanBoard_bA();

		this.Ab_tile_count_bA = 0;
		Reflect.deleteProperty(this, 'Ab_loop_info_bA');

		let __distance__ = v2();
		let list = data.map((tier, index, all)=>{
			let element: Array<{id: string, coor: Vec2, light: boolean}> = [];

			tier.element.forEach(el=>el.coor.forEach(c=>{
				let item = {id: el.id, coor: c, light: true};
				element.push(item);

				for(let t = index+1, end = all.length; t < end; t++){
					for(let _el_ of all[t].element){
						for(let _c_ of _el_.coor){
							Vec2.subtract(__distance__, _c_, c);
							if([__distance__.x, __distance__.y].every(v=>Math.abs(v)<1)){
								item.light = false;
								return void 0;
							}else continue;
						}
					}
				}
			}));

			element.sort((a,b)=>b.coor.y-a.coor.y);
			this.Ab_tile_count_bA += element.length;

			return {tier: tier.tier, element}
		});
		__distance__ = null;


		return this.Ab_prms_render_bA = this.Ab_updateFor_bA(list, tier=>{
			let record = this.Ab_createTier_bA(tier);
			this.Ab_tile_records_bA.push(record);
		}).then(()=>{
			this.Ab_tile_records_bA.sort((a, b)=>a.tier-b.tier);
			return 'end';
		});
	}

	private Ab_createTier_bA(info: {tier: number, element: {id: string, coor: Vec2, light: boolean}[]}){
		let tier_name = 'tier:'+info.tier;
		let record: typeof this.Ab_tile_records_bA[number] = {tier: info.tier, node: null, tiles: []};
		record.node = this.Ab_ui_container_bA.node.getChildByName(tier_name);
		if(!record.node){
			record.node = new Node(tier_name);
			record.node.setParent(this.Ab_ui_container_bA.node);
			let ui = record.node.addComponent(UITransform);
			ui.setContentSize(this.Ab_ui_container_bA.contentSize);
			ui.setAnchorPoint(0.5, 0.5);
			Vec3.zero(ui.node.position);
			record.node.setSiblingIndex(info.tier > 0 ? this.Ab_ui_container_bA.node.children.length : 0);
		}

		info.element.forEach(el=>{
			let tile = Ab_GameGameBoard_bA.Ab_getTile_bA();
			record.tiles.push({coor: el.coor, tile});

			tile.node.setParent(record.node);

			tile.Ab_init_bA(el.id, this.Ab_tile_size_bA);
			tile.Ab_setLight_bA(el.light);

			tile.node.setPosition(
				el.coor.x * this.Ab_tile_size_bA.width,
				el.coor.y * this.Ab_tile_size_bA.height,
				tile.node.position.z
			);
		});

		return record;
	}

	public Ab_appendingTile_bA(tier_idx: number, coor: Vec2, tile: Ab_Tile_bA){
		let tier = this.Ab_tile_records_bA.find(el=>el.tier==tier_idx);
		if(!tier) return void 0;
		tile.Ab_setSize_bA(this.Ab_tile_size_bA);
		let target_position = this.Ab_getPosition_bA(coor);
		target_position.z = tile.node.position.z;

		this.Ab_refreshLight_bA(tier_idx);

		return this.Ab_uitrans_bA.convertToWorldSpaceAR(target_position);
	}

	public Ab_appendedTile_bA(tier_idx: number, coor: Vec2, tile: Ab_Tile_bA){
		let tier = this.Ab_tile_records_bA.find(el=>el.tier==tier_idx);
		if(!tier) return void 0;

		let target_position = this.Ab_getPosition_bA(coor);

		tier.tiles.push({coor, tile});
		tier.tiles.sort((a, b)=>b.coor.y-a.coor.y);
		tile.node.removeFromParent();
		tile.node.setParent(tier.node);
		tile.node.setPosition(target_position);
		tile.node.setSiblingIndex(tier.tiles.findIndex(el=>el.tile==tile));
	}

	public Ab_removeTile_bA(tier_idx: number, tile: Ab_Tile_bA){
		this.Ab_testLoop_bA(tile);
		let tier = this.Ab_tile_records_bA.find(el=>el.tier==tier_idx);
		if(!tier) return void 0;

		let info = abi.Ab_array_bA.Ab_remove_bA(tier.tiles, el=>el.tile==tile);
		if(info) this.Ab_refreshLight_bA(tier_idx);
	}

	public Ab_shuffle_bA(){
		Ab_GameDC_bA.Ab_Status_bA.Ab_shuffling_bA = true;
		let radius = v2(...[this.Ab_uitrans_bA.width, this.Ab_uitrans_bA.height].map(v=>v/6));

		let tween_list: Tween<Node>[] = [];
		let duration = 3;
		let angle = 360 * 2;
		this.Ab_tile_records_bA.forEach(tier=>{
			let tier_rotation_tween = tween(tier.node).by(duration, {angle}, {easing: 'backInOut'}).set({angle: 0});
			tween_list.push(tier_rotation_tween);

			let [item_list, coor_list] = tier.tiles.reduce((acc, cur)=>{
				acc[0].push(cur);
				acc[1].push(cur.coor);
				return acc;
			}, [[], []] as [{coor: Vec2, tile: Ab_Tile_bA}[], Vec2[]]);

			item_list.sort(()=>Math.random()-0.5);
			coor_list.sort(()=>Math.random()-0.5);

			item_list.forEach((item, index)=>{
				item.tile.Ab_setLight_bA(true);
				item.coor = coor_list[index];

				let start = tween(item.tile.node).to(0.25 * duration, {position: v3(abi.Ab_number_bA.Ab_random_bA(-radius.x, radius.x), abi.Ab_number_bA.Ab_random_bA(-radius.y, radius.y))});
				let rotation = tween(item.tile.node).by(duration, {angle: -angle}, {easing: 'backInOut'}).set({angle: 0});
				let end = tween(item.tile.node).delay(0.75 * duration).to(0.25 * duration, {position: this.Ab_getPosition_bA(item.coor)});

				tween_list.push(tween(item.tile.node).parallel(start, rotation, end));
			});
		});

		tween_list.forEach(tw=>tw.start());
		abi.Ab_delay_bA(duration + 0.2, ()=>{
			Ab_GameDC_bA.Ab_Status_bA.Ab_shuffling_bA = false;
			this.Ab_tile_records_bA.forEach(tier=>{
				[...tier.node.children].sort((a, b)=>a.position.y-b.position.y).forEach((node, index)=>{
					node.setSiblingIndex(index);
				});
			});
			this.Ab_refreshLight_bA(this.Ab_tile_records_bA.Ab_lastElement_bA.tier);
		});
	}

	private Ab_loop_bA: {
		layout: Awaited<ReturnType<typeof Ab_GameAssets_bA.Ab_loadRoundLayout_bA>>;
		id_list: string[];
		count: number;
		check_list: Ab_Tile_bA[];
	};
	public Ab_setLoop_bA(layout: Awaited<ReturnType<typeof Ab_GameAssets_bA.Ab_loadRoundLayout_bA>>){
		let id_list = abi.Ab_array_bA.Ab_randomeElement_bA(abi.Ab_array_bA.Ab_create_bA(19, i=>(i+1).toString().padStart(2, '0')), 6);
		this.Ab_loop_bA = { layout, id_list, count: 0, check_list: [], };
		this.Ab_refreshLoop_bA();
	}

	private Ab_addLoop_bA(){
		let bucket = abi.Ab_array_bA.Ab_randomeElement_bA(this.Ab_loop_bA.id_list, 4).map(id=>{ return {id, count: 2} });

		abi.Ab_cc_bA.Ab_frameWhile_bA(this.Ab_loop_bA.layout, async el=>{
			let item: Parameters<typeof this.Ab_createTier_bA>[0] = {tier: -this.Ab_loop_bA.count-el.tier, element: []};
			el.coor.forEach(coor=>{
				let search = abi.Ab_array_bA.Ab_random_bA(bucket);
				while(search.count <= 0){
					abi.Ab_array_bA.Ab_remove_bA(bucket, search);
					search = abi.Ab_array_bA.Ab_random_bA(bucket);
				}
				search.count--;
				item.element.push({id: search.id, coor, light: false});
			});
			this.Ab_loop_bA.count++;
			let record = this.Ab_createTier_bA(item);
			this.Ab_tile_count_bA += record.tiles.length;
			this.Ab_tile_records_bA.unshift(record);
		}).then(()=>this.Ab_refreshLoop_bA());
	}

	private Ab_refreshLoop_bA(){
		if(!this.Ab_loop_bA || this.Ab_tileCount_bA==0) return void 0;

		let temp: Map<Vec2, {tier: number, tile: Ab_Tile_bA}[]> = new Map(this.Ab_loop_bA.layout.reduce((list, t)=>{
			t.coor.forEach(coor=>{
				let str = [coor.x, coor.y].join('::');
				if(list.includes(str)) return void 0;
				list.push(str);
			});
			return list;
		}, [] as string[]).map(el=>{
			let [x, y] = el.split('::').map(_=>Number(_));
			return [v2(x, y), []]
		}));

		this.Ab_tile_records_bA.forEach(t=>{
			t.tiles.forEach(tile=>{
				temp.forEach((list, coor)=>{
					if(tile.coor.x==coor.x && tile.coor.y==coor.y) list.push({tier: t.tier, tile: tile.tile});
				});
			});
		});

		abi.Ab_array_bA.Ab_clear_bA(this.Ab_loop_bA.check_list);

		for(let [coor, list] of temp){
			if(list.length<2){
				this.Ab_addLoop_bA();
				break;
			}
			this.Ab_loop_bA.check_list.push(list.sort((a, b)=>a.tier-b.tier)[1].tile);
		}
	}

	private Ab_testLoop_bA(tile: Ab_Tile_bA){
		if(!this.Ab_loop_bA) return void 0;
		if(this.Ab_loop_bA.check_list.includes(tile)) this.Ab_addLoop_bA();
	}

	private Ab_getPosition_bA(coor: Vec2, out?: Vec3){
		out = out ?? v3();
		out.set(
			coor.x * this.Ab_tile_size_bA.width,
			coor.y * this.Ab_tile_size_bA.height,
			out.z
		);
		return out;
	}

	protected Ab_recordToken_bA(record: {tier: number, coor: Vec2, tile: Ab_Tile_bA, token?: string}){
		if(record.token) return record.token;
		else record.token = [
			['id', record.tile.Ab_ID_bA],
			['tier', record.tier],
			['x', record.coor.x],
			['y', record.coor.y]
		].map(el=>el.join(':')).join('; ');

		return record.token;
	}

	private async Ab_initGuide_bA(){
		if([1, 2, 3, 4].every(id=>Ab_GameDC_bA.Ab_checkGuideID_bA(id))) return void 0;
		Ab_GameDC_bA.Ab_CleanGuideID_bA(1, 2, 3, 4);

		let np_guide = new abi.Ab_NudityPromise_bA<'end'>();
		if(Ab_GameDC_bA.Ab_Status_bA.Ab_guideInited_bA) np_guide.Ab_resolve_bA('end');
		else{
			let reg = Ab_DataTransfer_bA.Ab_follow_bA(Ab_GameDC_bA.Ab_Status_bA, 'Ab_guideInited_bA', ()=>{
				Ab_DataTransfer_bA.Ab_cancel_bA(reg);
				np_guide.Ab_resolve_bA('end');
			}, false);
		}
		await np_guide.Ab_promise_bA;



		let m = new Map<string, {tier: number, coor: Vec2, tile: Ab_Tile_bA}[]>();

		this.Ab_tile_records_bA.forEach(t=>{
			t.tiles.forEach(b=>{
				if(!b.tile.Ab_Light_bA) return void 0;

				let ls = m.get(b.tile.Ab_ID_bA);
				if(!ls){
					ls = [];
					m.set(b.tile.Ab_ID_bA, ls);
				}

				ls.push({tier: t.tier, ...b});
			});
		});

		let list = Array.from(m)
		.map(e=>e[1]).filter(e=>e.length>=3)
		.sort((a, b)=>Math.max(...a.map(e=>e.coor.y))-Math.max(...b.map(e=>e.coor.y)))
		.Ab_lastElement_bA.sort((a, b)=>a.coor.x-b.coor.x);

		let ui_drawer = find('drawer-container/guide-select', this.node.parent).getComponent(UITransform);

		Ab_GameGuide_bA.Ab_Create_bA(1,
			Ab_GameAssets_bA.Ab_getLangText_bA(58),
			ui_drawer,
			list[0].tile.node.getChildByName('background').getComponent(UITransform)
		);
		Ab_GameGuide_bA.Ab_Create_bA(2,
			Ab_GameAssets_bA.Ab_getLangText_bA(57),
			ui_drawer,
			list[1].tile.node.getChildByName('background').getComponent(UITransform)
		);
		Ab_GameGuide_bA.Ab_Create_bA(3,
			Ab_GameAssets_bA.Ab_getLangText_bA(57),
			ui_drawer,
			list[2].tile.node.getChildByName('background').getComponent(UITransform)
		);
		Ab_GameGuide_bA.Ab_Create_bA(4,
			"Eliminate all the bricks to clear the level",
			ui_drawer,
			null
		);

		Ab_GameGuide_bA.Ab_Show_bA(1);

		Ab_GameGuide_bA.Ab_Wait_bA(1, false).then(()=>{
			Ab_GameGameBoard_bA.Ab_select_call_list_bA.forEach(call=>call(list[0]));
			Ab_GameGuide_bA.Ab_Show_bA(2);
		});
		Ab_GameGuide_bA.Ab_Wait_bA(2, false).then(()=>{
			Ab_GameGameBoard_bA.Ab_select_call_list_bA.forEach(call=>call(list[1]));
			Ab_GameGuide_bA.Ab_Show_bA(3);
		});
		Ab_GameGuide_bA.Ab_Wait_bA(3, false).then(()=>{
			Ab_GameGameBoard_bA.Ab_select_call_list_bA.forEach(call=>call(list[2]));
			Ab_GameGuide_bA.Ab_Show_bA(4, 1.85);
		});
	}
}

